﻿@using YUCodeGen.Utils;
@{
    Layout = null;
    string classname = ViewData["ClassName"].ToString();
    string cat = ViewData["cat"].ToString();
    string compname = $"{classname.ToLower()}-{cat.ToLower()}";
    string compClassname = $"{classname}{PageUtil.Capitalize(cat)}";

    string createComponentName = $"{classname}CreateComponent";
    string listComponentName = $"{classname}ListComponent";
    string detailComponentName = $"{classname}DetailComponent";
}

import {Component,ViewChild} from '@@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators ,ReactiveFormsModule } from '@@angular/forms';
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA}  from '@@angular/material';
import {BsModalService,BsModalRef} from 'ngx-bootstrap/modal';
import { @(classname)detailComponent } from './@(classname)-detail.component';
import { @(classname)createComponent } from './@(classname)-create.component';

@@Component({
    selector: '@(compname)',
    templateUrl: '@(compname).component.html',
    styleUrls:["@(compname).component.css"]
    })
    export class @(compClassname)Component{

    @@ViewChild('detail',{ static:false}) objDetail:@(classname)detailComponent;
    @@ViewChild('create',{ static:false}) objCreate:@(classname)createComponent;

    modalRef:BsModalRef;

    objListShow=true;


    createNew(){
    const initialState = {parentComponent: this};
    this.modalRef = this.modalService.show(@(classname)createComponent,{initialState});
    }

    childCancel(childComp)
    {
    this.modalRef.hide();
    }

    showDetailWithData(data){
    this.modalRef.hide();
    const initialState = {parentComponent: this};
    this.modalRef = this.modalService.show(@(classname)detailComponent,{initialState});
    this.modalRef.content.setValue(data);
    }


    //getters for fields
    constructor(public dialog:MatDialog,private modalService:BsModalService){}
    }
